<%@ page language="java"  pageEncoding="UTF-8"%>
<%--为了避免在jsp页面中出现java代码，这里引入jstl标签库，利用jstl标签库提供的标签来做一些逻辑判断处理 --%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML>
<html>
<head>
  <title>首页</title>
  <script type="text/javascript">
    function doLogout(){
      //访问LogoutServlet注销当前登录的用户
      window.location.href="${pageContext.request.contextPath}/Servlet/LogoutServlet";
    }
  </script>
</head>

<body>
<div style="text-align: center">
  <h1 style="align-content: center; color: brown">ZW的网站</h1>
  <hr/>
  <c:if test="${user==null}">
    <a style="align-content: center; color: darkblue"
       href="${pageContext.request.contextPath}/Servlet/RegisterUIServlet" target="_blank">
      注册
    </a>
    <a style="color: darkgoldenrod"
       href="${pageContext.request.contextPath}/Servlet/LoginUIServlet">
      登陆
    </a>
  </c:if>
  <c:if test="${user!=null}">
    欢迎您：${user.userName}
    <input style="color: aquamarine" type="button" value="退出登陆" onclick="doLogout()">
  </c:if>
  <hr/>
</div>
</body>
</html>